package com.lzw.utils;

import com.lzw.contant.CodeContant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {

    private Integer code;
    private String msg;
    private Object data;


    public static R ok(Integer code,String message,Object data) {
        return new R(code,message, data);
    }
    public static R ok(String message,Object data) {
        return ok(CodeContant.SUCCESS_CODE,message, data);
    }
    public static R ok(Integer code,String message) {
        return ok(code,message, null);
    }
    public static R ok(Object data) {
        return ok(CodeContant.SUCCESS_CODE, "操作成功",data);
    }
    public static R ok(String message) {
        return ok(CodeContant.SUCCESS_CODE, message,null);
    }
    public static R ok() {
        return ok(CodeContant.SUCCESS_CODE, "操作成功",null);
    }


    public static R fail(Integer code,String message,Object data) {
        return new R(code, message, data);
    }
    public static R fail(Integer code,String message) {
        return fail(code,message, null);
    }
    public static R fail(String message,Object data) {
        return fail(CodeContant.FAIL_CODE,message, data);
    }
    public static R fail(Object data) {
        return fail(CodeContant.FAIL_CODE,"操作失败",data);
    }
    public static R fail(String message) {
        return fail(CodeContant.FAIL_CODE,message,null);
    }
    public static R fail() {
        return fail(CodeContant.FAIL_CODE,"操作失败",null);
    }

}
